<?php

use yii\db\Migration;

class m170607_024503_create_art_relation extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }

    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->createTable('{{%art_relation}}',[
                'art_teaching_id' => $this->integer(11)->defaultValue(0).' COMMENT \'艺教学id\'',
                'arrangement_id' => $this->integer(11)->defaultValue(0).' COMMENT \'排课表id\'',
                'lesson' => $this->integer(11)->defaultValue(0) .' COMMENT \'课次\'',
            ]);
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach($dbs as $v){
            $this->db = $v;
            $this->dropTable('{{%art_relation}}');
        }
    }
}
